const code = `class Person { constructor(name) { this.name = name; } }`;

const ast = parser.parse(code);

// 定义 visitor
const visitor = {
    ClassDeclaration(path) {
        console.log(`Found Class: ${path.node.id.name}`);
        path.node.id.name = 'Human'; // 将类名改为 Human
    }
};

// 遍历 AST
traverse(ast, visitor);

// 生成新的代码
const { code: transformedCode } = generate(ast);
console.log(transformedCode);